package com.cn.serverline.lineicp.workshopPlan.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cn.serverline.lineicp.workshopPlan.entity.AuxiliaryMaterials;
import com.cn.serverline.lineicp.workshopPlan.entity.request.AuxiliaryMaterialsRequest;
import com.cn.serverline.lineicp.workshopPlan.service.AuxiliaryMaterialsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 辅料类型控制层
 *
 * @author 田江余
 * @date 2024年7月29日
 */
@Api(tags = "辅料类型")
@RestController
@ApiResource(name = "辅料类型")
public class AuxiliaryMaterialsController {

    @Resource(name = "auxiliaryMaterialsServiceImpl")
    private AuxiliaryMaterialsService auxiliaryMaterialsService    ;


    /**
     * 添加
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "添加辅料类型")
    @PostResource(name = "添加", path = "/auxiliaryMaterials/add")
    public ResponseData<?> add(@RequestBody @Validated(AuxiliaryMaterialsRequest.add.class) AuxiliaryMaterialsRequest auxiliaryMaterialsRequest) {
        return new SuccessResponseData<>(auxiliaryMaterialsService.add(auxiliaryMaterialsRequest));
    }

    /**
     * 删除
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "删除辅料类型")
    @PostResource(name = "删除", path = "/auxiliaryMaterials/delete")
    public ResponseData<?> delete(@RequestBody @Validated(AuxiliaryMaterialsRequest.delete.class) AuxiliaryMaterialsRequest auxiliaryMaterialsRequest) {
        auxiliaryMaterialsService.del(auxiliaryMaterialsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "编辑辅料类型")
    @PostResource(name = "编辑", path = "/auxiliaryMaterials/edit")
    public ResponseData<?> edit(@RequestBody @Validated(AuxiliaryMaterialsRequest.edit.class) AuxiliaryMaterialsRequest auxiliaryMaterialsRequest) {
        auxiliaryMaterialsService.edit(auxiliaryMaterialsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 获取列表
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "查询辅料类型")
    @GetResource(name = "获取列表", path = "/auxiliaryMaterials/list")
    public ResponseData<Page<AuxiliaryMaterials>> list(AuxiliaryMaterialsRequest auxiliaryMaterialsRequest) {
        return new SuccessResponseData<>(auxiliaryMaterialsService.findList(auxiliaryMaterialsRequest));
    }
}
